@(table:String,path:String,name:String,fields:Map[String,String])
<meta title="@{name}列表"/>
<form class="form-inline" id="@{table}SearchForm" s="form"
      s-form="{action: function(){S.N('#page').val(1); @{table}Grid.refresh();}}">
    <input type="text" name="name" class="form-control" placeholder=""/>
    <input type="hidden" name="page" value="1" id="page"/>
    <!--<input type="hidden" name="pageSize" value="100"/>-->
    <input type="submit" class="btn btn-success" value="查找"/>
</form>
<div class="s-ui-grid-action">
    <input type="button" class="btn btn-sm btn-info" value="新建" s-click="create@{table}()"/>
    <input type="button" class="btn btn-sm btn-danger" value="删除" s-click="delete@{table}s()"/>
</div>
<table s="check,nda,datac" s-data="S.get('/api/admin/@{path}', S.N('#@{table}SearchForm').serialize())" id="@{table}Grid"
       class="table table-striped table-hover" style="width: 100%;">
    <thead>
    <tr>
        <th><input type="checkbox" s-check-role="checkall-h"/></th>
        @for(kv<-fields){
            <th >@{kv._2}</th>
        }
        <th style="width: 15%;" class="text-right">操作</th>
    </tr>
    </thead>
    <tbody s="loop" s-data-filter="'list'">
    <tr s-loop-role="empty">
        <td colspan="11">
            <div class="s-ui-none-data-info text-center"><i class="fa fa-info-circle text-info"></i> 未查询到数据</div>
        </td>
    </tr>
    <tr s-loop-role="loading">
        <td colspan="11">
            <div class="text-center" style="padding: 20px;"><i class="fa fa-spinner fa-spin fa-3x fa-fw"></i></div>
        </td>
    </tr>
    <tr s-loop-role="row" s-check-role="i" s="datac,row">
        <td><input type="checkbox" s-check-role="h"/></td>
        @for(kv<-fields){
            <td name="@{kv._1}"/></td>
        }
        <td class="text-right">
            <input type="button" class="btn btn-sm btn-link" s-click="edit@{table}(this)" value="编辑"/>
        </td>
    </tr>
    </tbody>
    <tfoot>
    <tr>
        <td colspan="11" class="s-ui-pagination-wrapper">
            <ul s="pagination" id="@{table}BillPagination"
                s-pagination="{action:function(){S.N('#page').val(this); @{table}Grid.refresh()}}"
                class="pagination pagination-sm pull-right" style="margin: 0">
            </ul>
            <div class="s-ui-pagination-info pull-right">共有<span name="allCount"></span>条记录</div>
        </td>
    </tr>
    </tfoot>
</table>
<script type="text/javascript">
    var @{table}Grid = S.S('#@{table}Grid');

    function create@{table}() {
        S.popupOpen('adminUser/@{table}-add.html').done(function (flag) {
            flag && @{table}Grid.refresh();
        })
    }

    function delete@{table}s() {
        var ids = @{table}Grid.getCheckedData('id');
        if (ids.length == 0) {
            S.notice("请选择需要删除的@{name}", 'warning');
            return;
        }
        S.confirm("确认删除所选@{name}吗？").done(function () {
            S.remove("/api/admin/@{path}/" + ids.join("_")).done(function () {
                @{table}Grid.refresh();
            });
        });
    }
    function edit@{table}(s) {
        S.popupOpen("adminUser/@{table}-edit.html", {@{table}: s.parent().data()}).done(function(@{table}){
            if(@{table}){@{table}Grid.refresh();}
        })
    }
</script>